<%@page import="cn.sendto.model.CarInfoModel"%>
<%@page import="cn.sendto.service.CarInfoService"%>
<%@page import="cn.sendto.model.ParkInfoModel"%>
<%@page import="cn.sendto.service.ParkInfoService"%>
<%@page import="cn.sendto.service.ResidentInfoService"%>
<%@page import="cn.sendto.model.ResidentInfoModel"%>
<%@page import="java.util.List"%>
<%@page import="java.util.ArrayList"%>
<%@page import="java.util.HashMap"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"  errorPage="../err.jsp"%>
    <jsp:include page="../lock.jsp"></jsp:include>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>添加设备信息</title>
<style>
.txt20 {
	font-size: 20px;
}

.td {
	font-size: 18px;
	height: 50px;
	text-align: right;
}
.star{
	font-size:12px;
	color:red;
}

</style>
</head>
<body>
		<div class="txt20">当前位置-->添加设备信息</div>
<div>
		<%
			if (request.getAttribute("addcarinfo") != null) {
				out.print(request.getAttribute("addcarinfo"));
			}
		%>
		<form action="doaddcar.jsp" method="post">
			<table width="95%"  cellspacing="1" cellpadding="0" align="center" 
			style="background-color: azure">
			<tr>
				<td colspan="2" height="30px" >
				</td>
				</tr>
				<tr>
					<td class="td" >设备编号：</td>
					<td><input type="text" name="SbID"
						value="<%request.setCharacterEncoding("UTF-8");
			HashMap<String, String> formlist = new HashMap<String, String>();
			if (request.getAttribute("form") != null) {
				formlist = (HashMap<String, String>) request.getAttribute("form");
			}
			if (formlist.get("carnum") != null) {
				out.print(formlist.get("carnum"));
			}%>">
						<%
							ArrayList<Integer> errlist = new ArrayList<Integer>();
							if (request.getAttribute("info") != null) {
								errlist = (ArrayList<Integer>) request.getAttribute("info");
							}
							for (int i = 0; i < errlist.size(); i++) {
								if (errlist.get(i) == 1) {
									out.println("<span class=\"star\">*请输入设备编号。</span>");
									break;
								}
							}
						%></td>
				</tr>
			
				<tr>
					<td class="td">设备名称：</td>
					<td><input type="text" name="Sbname"
						value="<%if (formlist.get("cartype") != null) {
				out.print(formlist.get("cartype"));
			}%>">
						<%
							for (int i = 0; i < errlist.size(); i++) {
								if (errlist.get(i) == 2) {
									out.println("<span class=\"star\">*请输入设备名称。</span>");
									break;
								}
							}
						%></td>
				</tr>
				<tr>
					<td class="td">设备型号：</td>
					<td><input type="text" name="Sbtype" value="<%if (formlist.get("color") != null) {
				out.print(formlist.get("color"));
			}%>">
			<%
							for (int i = 0; i < errlist.size(); i++) {
								if (errlist.get(i) == 3) {
									out.println("<span class=\"star\">*请输入设备型号。</span>");
									break;
								}
							}
						%>
			</td>
				</tr>
				<tr>
					<td class="td">负责人：</td>
					<td>
					<input type="text" name="Chargeman" 
					  value="<%if (formlist.get("drivenum") != null) {
				out.print(formlist.get("drivenum"));
			}%>">
						<%
							for (int i = 0; i < errlist.size(); i++) {
								if (errlist.get(i) == 4) {
									out.println("<span class=\"star\">*请输入负责人。</span>");
									break;
								}
							}
						%></td>
				</tr>
				<tr>
					<td class="td">说明状态：</td>
					<td><input type="text" name="Status"
						value="<%if (formlist.get("Status") != null) {
				out.print(formlist.get("Status"));
			}%>">
						<%
							for (int i = 0; i < errlist.size(); i++) {
								if (errlist.get(i) == 4) {
									out.println("<span class=\"star\">*请输入说明状态。</span>");
									break;
								}
							}
						%></td>
				</tr>
				<tr>
					<td class="td">所属教室：</td>
					<td>
					<select name="Department">
					 <%
					ParkInfoService pis = new ParkInfoService();
					 CarInfoService cis = new CarInfoService();
					List<ParkInfoModel> list1 = pis.allPark();
					if(list1.size() > 0){
						for (int i = 0; i < list1.size(); i++) {
							List<CarInfoModel>  lt  = cis.park(list1.get(i).getClassId());
							if(lt == null ||lt.size() <= 0 ){
					%>
					<option value="<%=list1.get(i).getClassName()%>"><%=list1.get(i).getClassName()%></option>
					<%
					}
					}}
					%>  
						</select>
						</td>
				</tr>
				<tr>
				<td></td>
					<td height="50px"><input type="submit" name="submit" value="提交" style="width:100px;height:25px"></td>
				</tr>
			</table>
		</form>
	</div>
</body>
</html>